Option Strict On
Option Explicit On 

Public Class UExpand
    Inherits System.Windows.Forms.UserControl

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'UserControl overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents cboChildRelation As System.Windows.Forms.ComboBox
    Friend WithEvents lblChildRelation As System.Windows.Forms.Label
    Friend WithEvents cboParentRelation As System.Windows.Forms.ComboBox
    Friend WithEvents lblParentRelation As System.Windows.Forms.Label
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(UExpand))
        Me.cboChildRelation = New System.Windows.Forms.ComboBox
        Me.lblChildRelation = New System.Windows.Forms.Label
        Me.cboParentRelation = New System.Windows.Forms.ComboBox
        Me.lblParentRelation = New System.Windows.Forms.Label
        Me.SuspendLayout()
        '
        'cboChildRelation
        '
        Me.cboChildRelation.AccessibleDescription = resources.GetString("cboChildRelation.AccessibleDescription")
        Me.cboChildRelation.AccessibleName = resources.GetString("cboChildRelation.AccessibleName")
        Me.cboChildRelation.Anchor = CType(resources.GetObject("cboChildRelation.Anchor"), System.Windows.Forms.AnchorStyles)
        Me.cboChildRelation.BackgroundImage = CType(resources.GetObject("cboChildRelation.BackgroundImage"), System.Drawing.Image)
        Me.cboChildRelation.Dock = CType(resources.GetObject("cboChildRelation.Dock"), System.Windows.Forms.DockStyle)
        Me.cboChildRelation.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.cboChildRelation.Enabled = CType(resources.GetObject("cboChildRelation.Enabled"), Boolean)
        Me.cboChildRelation.Font = CType(resources.GetObject("cboChildRelation.Font"), System.Drawing.Font)
        Me.cboChildRelation.ImeMode = CType(resources.GetObject("cboChildRelation.ImeMode"), System.Windows.Forms.ImeMode)
        Me.cboChildRelation.IntegralHeight = CType(resources.GetObject("cboChildRelation.IntegralHeight"), Boolean)
        Me.cboChildRelation.ItemHeight = CType(resources.GetObject("cboChildRelation.ItemHeight"), Integer)
        Me.cboChildRelation.Location = CType(resources.GetObject("cboChildRelation.Location"), System.Drawing.Point)
        Me.cboChildRelation.MaxDropDownItems = CType(resources.GetObject("cboChildRelation.MaxDropDownItems"), Integer)
        Me.cboChildRelation.MaxLength = CType(resources.GetObject("cboChildRelation.MaxLength"), Integer)
        Me.cboChildRelation.Name = "cboChildRelation"
        Me.cboChildRelation.RightToLeft = CType(resources.GetObject("cboChildRelation.RightToLeft"), System.Windows.Forms.RightToLeft)
        Me.cboChildRelation.Size = CType(resources.GetObject("cboChildRelation.Size"), System.Drawing.Size)
        Me.cboChildRelation.TabIndex = CType(resources.GetObject("cboChildRelation.TabIndex"), Integer)
        Me.cboChildRelation.Text = resources.GetString("cboChildRelation.Text")
        Me.cboChildRelation.Visible = CType(resources.GetObject("cboChildRelation.Visible"), Boolean)
        '
        'lblChildRelation
        '
        Me.lblChildRelation.AccessibleDescription = resources.GetString("lblChildRelation.AccessibleDescription")
        Me.lblChildRelation.AccessibleName = resources.GetString("lblChildRelation.AccessibleName")
        Me.lblChildRelation.Anchor = CType(resources.GetObject("lblChildRelation.Anchor"), System.Windows.Forms.AnchorStyles)
        Me.lblChildRelation.AutoSize = CType(resources.GetObject("lblChildRelation.AutoSize"), Boolean)
        Me.lblChildRelation.Dock = CType(resources.GetObject("lblChildRelation.Dock"), System.Windows.Forms.DockStyle)
        Me.lblChildRelation.Enabled = CType(resources.GetObject("lblChildRelation.Enabled"), Boolean)
        Me.lblChildRelation.Font = CType(resources.GetObject("lblChildRelation.Font"), System.Drawing.Font)
        Me.lblChildRelation.Image = CType(resources.GetObject("lblChildRelation.Image"), System.Drawing.Image)
        Me.lblChildRelation.ImageAlign = CType(resources.GetObject("lblChildRelation.ImageAlign"), System.Drawing.ContentAlignment)
        Me.lblChildRelation.ImageIndex = CType(resources.GetObject("lblChildRelation.ImageIndex"), Integer)
        Me.lblChildRelation.ImeMode = CType(resources.GetObject("lblChildRelation.ImeMode"), System.Windows.Forms.ImeMode)
        Me.lblChildRelation.Location = CType(resources.GetObject("lblChildRelation.Location"), System.Drawing.Point)
        Me.lblChildRelation.Name = "lblChildRelation"
        Me.lblChildRelation.RightToLeft = CType(resources.GetObject("lblChildRelation.RightToLeft"), System.Windows.Forms.RightToLeft)
        Me.lblChildRelation.Size = CType(resources.GetObject("lblChildRelation.Size"), System.Drawing.Size)
        Me.lblChildRelation.TabIndex = CType(resources.GetObject("lblChildRelation.TabIndex"), Integer)
        Me.lblChildRelation.Text = resources.GetString("lblChildRelation.Text")
        Me.lblChildRelation.TextAlign = CType(resources.GetObject("lblChildRelation.TextAlign"), System.Drawing.ContentAlignment)
        Me.lblChildRelation.Visible = CType(resources.GetObject("lblChildRelation.Visible"), Boolean)
        '
        'cboParentRelation
        '
        Me.cboParentRelation.AccessibleDescription = resources.GetString("cboParentRelation.AccessibleDescription")
        Me.cboParentRelation.AccessibleName = resources.GetString("cboParentRelation.AccessibleName")
        Me.cboParentRelation.Anchor = CType(resources.GetObject("cboParentRelation.Anchor"), System.Windows.Forms.AnchorStyles)
        Me.cboParentRelation.BackgroundImage = CType(resources.GetObject("cboParentRelation.BackgroundImage"), System.Drawing.Image)
        Me.cboParentRelation.Dock = CType(resources.GetObject("cboParentRelation.Dock"), System.Windows.Forms.DockStyle)
        Me.cboParentRelation.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.cboParentRelation.Enabled = CType(resources.GetObject("cboParentRelation.Enabled"), Boolean)
        Me.cboParentRelation.Font = CType(resources.GetObject("cboParentRelation.Font"), System.Drawing.Font)
        Me.cboParentRelation.ImeMode = CType(resources.GetObject("cboParentRelation.ImeMode"), System.Windows.Forms.ImeMode)
        Me.cboParentRelation.IntegralHeight = CType(resources.GetObject("cboParentRelation.IntegralHeight"), Boolean)
        Me.cboParentRelation.ItemHeight = CType(resources.GetObject("cboParentRelation.ItemHeight"), Integer)
        Me.cboParentRelation.Location = CType(resources.GetObject("cboParentRelation.Location"), System.Drawing.Point)
        Me.cboParentRelation.MaxDropDownItems = CType(resources.GetObject("cboParentRelation.MaxDropDownItems"), Integer)
        Me.cboParentRelation.MaxLength = CType(resources.GetObject("cboParentRelation.MaxLength"), Integer)
        Me.cboParentRelation.Name = "cboParentRelation"
        Me.cboParentRelation.RightToLeft = CType(resources.GetObject("cboParentRelation.RightToLeft"), System.Windows.Forms.RightToLeft)
        Me.cboParentRelation.Size = CType(resources.GetObject("cboParentRelation.Size"), System.Drawing.Size)
        Me.cboParentRelation.TabIndex = CType(resources.GetObject("cboParentRelation.TabIndex"), Integer)
        Me.cboParentRelation.Text = resources.GetString("cboParentRelation.Text")
        Me.cboParentRelation.Visible = CType(resources.GetObject("cboParentRelation.Visible"), Boolean)
        '
        'lblParentRelation
        '
        Me.lblParentRelation.AccessibleDescription = resources.GetString("lblParentRelation.AccessibleDescription")
        Me.lblParentRelation.AccessibleName = resources.GetString("lblParentRelation.AccessibleName")
        Me.lblParentRelation.Anchor = CType(resources.GetObject("lblParentRelation.Anchor"), System.Windows.Forms.AnchorStyles)
        Me.lblParentRelation.AutoSize = CType(resources.GetObject("lblParentRelation.AutoSize"), Boolean)
        Me.lblParentRelation.Dock = CType(resources.GetObject("lblParentRelation.Dock"), System.Windows.Forms.DockStyle)
        Me.lblParentRelation.Enabled = CType(resources.GetObject("lblParentRelation.Enabled"), Boolean)
        Me.lblParentRelation.Font = CType(resources.GetObject("lblParentRelation.Font"), System.Drawing.Font)
        Me.lblParentRelation.Image = CType(resources.GetObject("lblParentRelation.Image"), System.Drawing.Image)
        Me.lblParentRelation.ImageAlign = CType(resources.GetObject("lblParentRelation.ImageAlign"), System.Drawing.ContentAlignment)
        Me.lblParentRelation.ImageIndex = CType(resources.GetObject("lblParentRelation.ImageIndex"), Integer)
        Me.lblParentRelation.ImeMode = CType(resources.GetObject("lblParentRelation.ImeMode"), System.Windows.Forms.ImeMode)
        Me.lblParentRelation.Location = CType(resources.GetObject("lblParentRelation.Location"), System.Drawing.Point)
        Me.lblParentRelation.Name = "lblParentRelation"
        Me.lblParentRelation.RightToLeft = CType(resources.GetObject("lblParentRelation.RightToLeft"), System.Windows.Forms.RightToLeft)
        Me.lblParentRelation.Size = CType(resources.GetObject("lblParentRelation.Size"), System.Drawing.Size)
        Me.lblParentRelation.TabIndex = CType(resources.GetObject("lblParentRelation.TabIndex"), Integer)
        Me.lblParentRelation.Text = resources.GetString("lblParentRelation.Text")
        Me.lblParentRelation.TextAlign = CType(resources.GetObject("lblParentRelation.TextAlign"), System.Drawing.ContentAlignment)
        Me.lblParentRelation.Visible = CType(resources.GetObject("lblParentRelation.Visible"), Boolean)
        '
        'UExpand
        '
        Me.AccessibleDescription = resources.GetString("$this.AccessibleDescription")
        Me.AccessibleName = resources.GetString("$this.AccessibleName")
        Me.AutoScroll = CType(resources.GetObject("$this.AutoScroll"), Boolean)
        Me.AutoScrollMargin = CType(resources.GetObject("$this.AutoScrollMargin"), System.Drawing.Size)
        Me.AutoScrollMinSize = CType(resources.GetObject("$this.AutoScrollMinSize"), System.Drawing.Size)
        Me.BackgroundImage = CType(resources.GetObject("$this.BackgroundImage"), System.Drawing.Image)
        Me.Controls.Add(Me.cboParentRelation)
        Me.Controls.Add(Me.lblParentRelation)
        Me.Controls.Add(Me.cboChildRelation)
        Me.Controls.Add(Me.lblChildRelation)
        Me.Enabled = CType(resources.GetObject("$this.Enabled"), Boolean)
        Me.Font = CType(resources.GetObject("$this.Font"), System.Drawing.Font)
        Me.ImeMode = CType(resources.GetObject("$this.ImeMode"), System.Windows.Forms.ImeMode)
        Me.Location = CType(resources.GetObject("$this.Location"), System.Drawing.Point)
        Me.Name = "UExpand"
        Me.RightToLeft = CType(resources.GetObject("$this.RightToLeft"), System.Windows.Forms.RightToLeft)
        Me.Size = CType(resources.GetObject("$this.Size"), System.Drawing.Size)
        Me.ResumeLayout(False)

    End Sub

#End Region

    Public Event ValueChanged As EventHandler

    Private Sub UExpand_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        AddHandler cboChildRelation.SelectionChangeCommitted, AddressOf OnValueChanged
        AddHandler cboParentRelation.SelectionChangeCommitted, AddressOf OnValueChanged
    End Sub

    Protected Sub OnValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        RaiseEvent ValueChanged(Me, New EventArgs)
    End Sub

    Public Sub Prepare(ByVal section As Model10.Section)
        cboChildRelation.Items.Clear()

        Dim rel As Model10.Relation
        '-------------------
        For Each rel In section.Table.Presentation.Relations
            cboChildRelation.Items.Add(rel)
        Next : rel = Nothing
        '-------------------
        cboParentRelation.Items.Clear()

        For Each rel In section.Table.Presentation.Relations
            cboParentRelation.Items.Add(rel)
        Next : rel = Nothing
    End Sub

    Public Sub Read(ByVal expand As Model10.Expand)
        cboChildRelation.SelectedItem = expand.ChildRelation
        cboParentRelation.SelectedItem = expand.ParentRelation
    End Sub
    Public Sub Write(ByVal expand As Model10.Expand)
        expand.ChildRelation = CType(cboChildRelation.SelectedItem, Model10.Relation)
        expand.ParentRelation = CType(cboParentRelation.SelectedItem, Model10.Relation)
    End Sub
End Class
